#!ipxe

:live_menu
set os Manjaro
menu ${os} Live - Current Arch [ ${arch} ]
iseq ${arch} x86_64 && set arch_a amd64 || set arch_a ${arch}
set ipparam BOOTIF=${netX/mac} ip=dhcp net.ifnames=0
item --gap ${os} Live versions
item current ${space} ${os} Current Stable (20.x)
item stable ${space} ${os} Old Stable (18.1.0)
choose menu || goto live_exit
goto ${menu}

:stable
menu ${os} Live Stable - Current Arch [ ${arch} ]
item --gap Currently during boot you need to press ctrl+d/ctrl+c
item --gap repeatedly when init hangs on starting a download
{% for key, value in endpoints.items() | sort %}
{% if value.os == "manjaro" and value.version == "18.1.0" and "kernel" not in key %}
item {{ value.version }}-{{ value.flavor }} ${space} ${os} {{ value.version }} {{ value.flavor }}
{% endif %}
{% endfor %}
choose version || goto live_menu
goto ${version}

:current
menu ${os} Live Current - Current Arch [ ${arch} ]
item --gap ${os} Versions
{% for key, value in endpoints.items() | sort %}
{% if value.os == "manjaro" and value.version == "current" %}
item {{ value.version }}-{{ value.flavor }} ${space} ${os} {{ value.version }} {{ value.flavor }}
{% endif %}
{% endfor %}
choose version || goto live_menu
goto ${version}

{% for key, value in endpoints.items() | sort %}
{% if value.os == "manjaro" and value.version == "current" %}
:{{ value.version }}-{{ value.flavor }}
set fetch_url ${live_endpoint}{{ value.path }}
set kernel_url ${live_endpoint}{{ value.path }}
goto boot
{% endif %}
{% endfor %}

{% for key, value in endpoints.items() | sort %}
{% if value.os == "manjaro" and value.version == "18.1.0" and 'kernel' not in key %}
{% set kernel_name = value.kernel %}
:{{ value.version }}-{{ value.flavor }}
set fetch_url ${live_endpoint}{{ value.path }}
{% for key, value in endpoints.items() | sort %}
{% if key == kernel_name %}
set kernel_url ${live_endpoint}{{ value.path }}
{% endif %}
{% endfor %}
goto boot
{% endif %}
{% endfor %}

:boot
imgfree
kernel ${kernel_url}vmlinuz misobasedir=manjaro ${ipparam} miso_http_srv=${fetch_url} nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 driver=free tz=UTC lang=en_US keytable=us initrd=initrd ${cmdline}
initrd ${kernel_url}initrd
boot

:live_exit
clear menu
exit 0
